﻿#pragma once

#include "../../common/utils/BinaryFileReader.h"
#include "render/IVideoRenderView.h"
#include <thread>
#include <QString>
#include <functional>

struct AVFrame;

class MultipleVideosPlayController
{
private:
	IVideoRenderView* iVideoRenderView = NULL;
	bool isRunning = true;
	std::unique_ptr<std::thread> renderThread;
	char* data = NULL;
	int linesize = 0;
	BinaryFileReader* binaryFileReader = nullptr;
public:
	int mWidth = 0;
	int mHeight = 0;
	int fps = 25;//fps默认25帧每秒
	IVideoRenderView::PixFormat mPixFormat = IVideoRenderView::PixFormat::RGBA;
	void* win_id = NULL;
	QString mFilePath = NULL;
	std::function<void(int)> callback;

public:
	static MultipleVideosPlayController* Create()
	{
		return new MultipleVideosPlayController();
	}
	QString Init();
	void Close();
	void Start();//开启线程
	void Draw();
	void Resize(int width, int height);
	
private:
	AVFrame* GetFrame(char* data);
public:
	MultipleVideosPlayController();
	~MultipleVideosPlayController();
};
